<!doctype html>
<html>

<head>
<meta charset="utf-8">
<title>后台管理模板</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="utf-8">
<link rel="stylesheet" href="@{'/public/plugins/layui/css/layui.css'}"
	media="all">
<link rel="stylesheet" href="@{'/public/css/sweetalert2.min.css'}">
<script src="@{'public/plugins/layui/layui.js'}"></script>
<script src="@{'public/js/jquery-2.1.4.min.js'}"></script>
<script src="@{'public/js/sweetalert2.min.js'}"></script>


</head>
<body>
	
		
	
	<div class="edit-innerWarning"  style="padding: 17px 0 20px 30px;">
		<form class="layui-form" id="updateDataForm" action="">


			<input id="id" name="news.id" type="hidden" value="${object.id}" />

			<div class="layui-form-item layui-block">
				<label class="layui-form-label">标题</label>
				<div class="layui-input-inline">
					<input type="text" name="news.title" value="${object.title}" required lay-verify="required"
						placeholder="必填项" class="layui-input">
				</div>
			</div>
			
			<div class="layui-form-item layui-block">
				<label class="layui-form-label">轮播图片</label>
				<div class="layui-input-block"  id="commoditysImgsDiv">
					
					<a href="javascript:aaa()" class="layui-btn layui-btn-small" id="parentIframe">选择</a>

					<img src="${object.img}" height="25px" width="50px"></img>
	
					<input id="commoditysImgs" type="hidden" name="news.img" value="${object.img}"/>
					
				</div>
			</div>



			<div class="layui-form-item layui-block">
				<label class="layui-form-label">作者</label>
				<div class="layui-input-inline">
					<input type="text" name="news.author" value="${object.author}" required 
						placeholder="100*100" class="layui-input">
				</div>
			</div>


			
			
			<div class="layui-form-item layui-block">
				<label class="layui-form-label">链接</label>
				<div class="layui-input-inline">
					<input type="text" name="author.links" required 
						placeholder="XX"  class="layui-input"  value="${object.links}" >
				</div>
			</div>
			
			

			
			
			<div class="layui-form-item layui-block">
				<label class="layui-form-label">是否在首页显示</label>
				<div class="layui-input-inline">
				
					<input type="checkbox" name="news.isShow" lay-skin="switch"
						lay-filter="switchTest" value="1" lay-text="启用|停用">
				</div>
			</div>
			
			
			<div class="layui-form-item layui-block">
				<label class="layui-form-label">内容</label>
				<div class="layui-input-inline">
					<!-- 加载编辑器的容器 -->
				    <script id="container" type="text/plain"></script>
					<input id="Hidintroduce" type="hidden" name="news.content" >
				</div>
			</div>
	
 		
			  <!-- 查看富文本编辑器的内容 -->
			  
		
			 
			 
			<div class="layui-form-item">
				<div class="layui-input-block">
					<a href="javascript:updateById()" class="layui-btn layui-btn-small">确认</a>
					<a href="javascript:close()" class="layui-btn layui-btn-primary layui-btn-small">取消</a>
				</div>
			 </div>
			 
		</form>
	</div>
	

    <!-- 配置文件 -->
    <script type="text/javascript" src="@{'public/ueditor/utf8-jsp/ueditor.config.js'}"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="@{'public/ueditor/utf8-jsp/ueditor.all.js'}"></script>
 
 
    <!-- 实例化编辑器 -->
    <script type="text/javascript">
    
	    var map={};
		var index = 1;
	
	
        var ue = UE.getEditor('container');
        
        UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
        UE.Editor.prototype.getActionUrl = function(action) {
          	if (action == 'uploadimage' || action == 'uploadscrawl' || action == 'uploadimage') {
            	
                return '@{UeDitorController.uploadfile()}';
                  
            } else if (action == 'uploadfile') {
                return '@{UeDitorController.uploadfile()}';
                
            } else if (action == 'listimage') {
            	
            	return '@{UeDitorController.getFiles()}';
                
            }else if (action == 'uploadvideo') {
            	
            	return '@{UeDitorController.uploadVideo()}';
                
            } else {
                return this._bkGetActionUrl.call(this, action);
            }
        }
        
        
        function aaa(){
        	
        	layer.open({
        		  type: 2,
        		  area: ['700px', '450px'],
        		  fixed: false, //不固定
        		  maxmin: true,
        		  content: '/upFileT?maxIndex='+1,	
        		  end: function(){ 
							
        			  $("#commoditysImgsDiv img").remove()
        			  $("#commoditysImgs").val("");
						var str='';
							
        			  	for(var key in map){ 
        			  		
        			  		var img ='<img src="${img_path}'+key+'" height="25px" width="50px"></img>';
        			  		str = '${img_path}'+key;
        			  		$("#commoditysImgsDiv").append(img);
        		
        			  	}
        			  		
        			  	$("#commoditysImgs").val(str);
        			}   	
        		});
        }
        

		
		
        layui.use([ 'layer', 'form' ], function() {
			var layer = layui.layer, form = layui.form;
			
		});

		layui.use('table', function() {
			var table = layui.table;

		});
		
		//特殊字符转义
		function escape2Html(str) {
			 var arrEntities={'lt':'<','gt':'>','nbsp':' ','amp':'&','quot':'"'};
			 return str.replace(/&(lt|gt|nbsp|amp|quot);/ig,function(all,t){return arrEntities[t];});
		}
		
		//初始化富文本框的内容
		$(function(){
			var value = escape2Html('${object.content}');
			$("#container").html(value);
		});

		
		//关闭弹窗
		function close() {
			window.history.back();
		}
		
		
		//更新数据
		function updateById() {


			$("#Hidintroduce").val(UE.getEditor('container').getContent());

			$.ajax({
				url : "@{manage.updateOrAddNews()}",
				type : "GET",
				async : false,
				data : $("#updateDataForm").serialize(),
				success : function(data) {
					layer.closeAll()
					swal('提示信息',
							  '添加成功',
							  'success',''
							).then(function () {
								window.location.href="/newsManage";
							})
				},
				error : function(data) {
					layer.alert("您的账户可能出现异常，请重新刷新获取账号信息!");
				}
			}); 
	
		}
		
    </script>
    
    
           
</body>
</html>